#!/bin/bash
 
 Mng_Backend_Deploy_Path=/usr/dp/ljy/todp-project-mng-web
 Mng_JAR_NAME=todp-project-mng-web.jar
 Mng_JAR_Dir=todp-auth-web
 Mng_SERVER_PORT=8284
 LOG_PATH=${Mng_Backend_Deploy_Path}/logs
  
 # check related dir
 if [ ! -f "${Mng_Backend_Deploy_Path}/${Mng_JAR_NAME}" ];then
     echo "todp-project-mng-web.jar is not exit!"
     exit -1
 fi
 
 # stop existing service
 pid=`lsof -t -i:${Mng_SERVER_PORT}`
 if [ -n "$pid" ];then
     echo 'old service is stopping...'
     sudo kill -9 $pid && echo "old service stopped! psid: ${pid}"
 fi
 
 # start service
 echo 'new service is starting...'
 nohup java -Dlog.path=${LOG_PATH} -jar ${Mng_Backend_Deploy_Path}/${Mng_JAR_NAME} --server.port=${Mng_SERVER_PORT} &
 
 echo "new service started! psid: $!"
